﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_ViewMenu.cshtml";
}
@using ZX.HIS.Model;
@{
    ZX.HIS.Model.MeasuringUnit mode = ViewData["tt"] as ZX.HIS.Model.MeasuringUnit;
}
<script src="~/Content/After/js/jquery.autoTextarea.js"></script>
<div id="urHere">DouPHP 管理中心<b>&gt;</b><strong>挂号信息</strong> </div>

<div style="width:100%">
    <div class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
        <script src="~/Content/After/js/jquery.autoTextarea.js"></script>
        <div style="width:60%;float:left">
            <h3>单次剂量信息</h3>

            <form action="product_category.php?rec=insert" method="post">
                <table width="100%" class="table table-bordered  tableBasic">
                    <thead>
                        <tr>
                            <th width="40" align="left"></th>
                            <th align="left">诊所名称</th>
                            <th align="left">单词剂量单位</th>
                        </tr>
                    </thead>
                    <tbody id="tbodyShow">
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="9" class="divPage"></td>
                        </tr>
                    </tfoot>
                </table>
            </form>
        </div>

        <div style="width:35%;float:left;padding:0 20px">
            <h3>新增单次剂量</h3>
            @if (mode == null)
            {
                <form action="/MeasuringUnit/AddMeasuringUnit" method="post">
                    <table width="100%" class="table table-bordered  tableBasic">
                        <tbody>
                            <tr>
                                <td width="90" align="right">序号</td>
                                <td>
                                    <input type="text" name="cat_name" value="" size="22" class="inpMain">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">诊所名称</td>
                                <td>
                                    <input type="text" name="cat_name" value="" size="22" class="inpMain">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">单次剂量单位</td>
                                <td>
                                    <input type="text" name="unique_id" value="" size="22" class="inpMain">
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <input type="hidden" name="token" value="b9439ae8">
                                    <input type="hidden" name="cat_id" value="">
                                    <input name="submit" class="btn" type="submit" value="提交">
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </form>
            }
            else
            {
                <form method="post" action="/MeasuringUnit/MeasuringUnitUpt">
                    <table width="100%" class="table table-bordered  tableBasic">
                        <tbody>
                            <tr>
                                <td width="50" align="right">序号</td>
                                <td>
                                    <input type="text" disabled name="MeasuringUnitId" value="@mode.MeasuringUnitId" size="22" class="inpMain">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">诊所名称</td>
                                <td>
                                    <input type="text" name="HospitalId" value="@mode.HospitalId" size="22" class="inpMain">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">单次剂量单位</td>
                                <td>
                                    <input type="text" name="MeasuringUnitName" value="@mode.MeasuringUnitName" size="22" class="inpMain">
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <input type="hidden" name="token" value="b9439ae8">
                                    <input type="hidden" name="MeasuringUnitId" value="@mode.MeasuringUnitId">
                                    <input name="submit" class="btn" type="submit" value="提交">
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </form>
            }
        </div>
    </div>
</div><div class="clear"></div>
<script>

    $(function () {
        //页面初次加载，调用AJAX，PageIndex 为1

        PageJump(1);

    })
    //分页数据加载方法
    function PageJump(PageIndex) {
        var PageSize = $("#PageSize").val();
        if (PageSize == "" || parseInt(PageSize) == 0 || PageSize == null) {
            PageSize = 10;
        }
        $.ajax({
            type: "POST",
            url: "/MeasuringUnit/FnMeasuringUnitList",
            data: {
                PageSize: PageSize,
                PageIndex: PageIndex

            },
            success: function (data) {
                var TrDemo = new Array();
                var divDemo = new Array();
                if (data.PageList.length == 0) {
                    TrDemo.push("<tr><td colspan=\"9\" >无查询结果</td></tr>")
                } else {
                    for (var i = 0; i < data.PageList.length; i++) {
                        TrDemo.push(" <tr>")
                        TrDemo.push(" <td width=\"40\" style=\"text-align:center\"><input id=\"CK\" onclick=\"RadioSelect(this)\"  type=\"radio\" name=\"CkOne\" value=\"");
                        TrDemo.push(data.PageList[i].MeasuringUnitId);
                        TrDemo.push("\" /></td><td style=\"text-align:left\">")
                        TrDemo.push(data.PageList[i].HospitalName);
                        TrDemo.push("</td><td style=\"text-align:left\">")
                        TrDemo.push(data.PageList[i].MeasuringUnitName);


                        TrDemo.push("</td></tr>")
                    }
                    PageDemoSuccess(divDemo, data);
                    $(".divPage").html(divDemo.join(""));
                }
                $("#tbodyShow").html(TrDemo.join(""));

                //调用分页索引条
            }
        })
    }
    //分页索引条加载方法
    function PageDemoSuccess(divDemo, data) {
        divDemo.push("<nav>")
        divDemo.push("<ul class=\"pagination \">")
        divDemo.push("<li>")
        divDemo.push(" <span>每页");
        divDemo.push("<input type=\"number\" class=\"inpMain\"  min=\"1\" style=\"width:40px;height:5px\" id=\"PageSize\" value=\"")
        divDemo.push(data.PageSize);
        divDemo.push("\" placeholder=\"\" />");
        divDemo.push(" 条</span></li>")
        divDemo.push("<li><span>共" + data.PageCount + "页，第" + data.PageIndex + "页，共" + data.PageNum + "条</span></li>")
        divDemo.push("<li><span onclick=\"PageJump(1)\" aria-label=\"Previous\"><span aria-hidden=\"true\">首页</span></span></li>")
        if (data.PageIndex <= 1) {
            divDemo.push("<li class=\"disabled\"><span onclick=\"PageJump(1)\">上一页</span></li>")
        }
        else {
            divDemo.push("<li><span onclick=\"PageJump(" + (data.PageIndex - 1) + ")\">上一页</span></li>")
        }
        for (var i = 0; i < data.PageCount; i++) {
            if (data.PageCount > 8) {
                if (data.PageIndex == 1) {
                    if (i <= 3) {
                        if (i == 3) {
                            LiNoPush(divDemo);
                        } else {
                            LiJumpPush(data.PageIndex, i, divDemo)
                        }
                    } else {
                        break;
                    }
                }
                else if (data.PageIndex == data.PageCount) {

                    if (i >= (data.PageCount - 4)) {
                        if (i == data.PageCount - 4) {
                            LiNoPush(divDemo);
                        } else {
                            LiJumpPush(data.PageIndex, i, divDemo)
                        }
                    }
                    else {
                        continue;
                    }
                } else {
                    if ((data.PageIndex - 3) <= i && i <= (data.PageIndex + 1)) {
                        if (data.PageIndex - 3 == i) {
                            LiNoPush(divDemo);
                        } else if (data.PageIndex + 1 == i) {
                            LiNoPush(divDemo);
                        } else {
                            LiJumpPush(data.PageIndex, i, divDemo)
                        }
                    } else {
                        continue;
                    }
                }
            } else {
                LiJumpPush(data.PageIndex, i, divDemo)
            }
        }
        if (data.PageIndex == data.PageCount) {
            divDemo.push("<li class=\"disabled\"><span onclick=\"PageJump(" + data.PageCount + ")\">下一页</span></li>")
        }
        else {
            divDemo.push("<li><span onclick=\"PageJump(" + (data.PageIndex + 1) + ")\">下一页</span></li>")
        }
        divDemo.push(" <li><span onclick=\"PageJump(" + data.PageCount + ")\" aria-label=\"Next\"><span aria-hidden=\"true\">尾页</span></span></li>")
        divDemo.push("</ul>")
        divDemo.push("</nav>")
    }
    //分页链接跳转方法
    function LiJumpPush(PageIndex, Num, Demo) {
        Demo.push("<li ")
        if (PageIndex == (Num + 1)) {
            Demo.push(" class=\"active\"")
        }
        Demo.push("><span onclick=\"PageJump(" + (Num + 1) + ")\">" + (Num + 1) + "</span></li>")
    }
    //省略号加载方法
    function LiNoPush(Demo) {
        Demo.push("<li><span>...</span></li>")
    }
    function RadioSelect(e) {
        var id = $(e).val();
        location.href = "/MeasuringUnit/UpateDrugage/" + id;

    }
    //$(function () {
    //    $("#CK").click(function () {
    //        alert(1)
    //
    //    })
    //})

</script>





